﻿using OnWork.DataCenter.DAL.Common;
using SqlSugar;
using System.ComponentModel;

namespace OnWork.DataCenter.DAL.DataCenter
{
    /// <summary>
    /// 任务类型
    /// </summary>
    public enum DSTaskType
    {
        /// <summary>
        /// 流程处理
        /// </summary>
        [Description("流程处理")]
        Process = 0,

        /// <summary>
        /// 执行Exe
        /// </summary>
        [Description("执行Exe程序")]
        Exe = 1,
    }

    /// <summary>
    /// 任务日期类型
    /// </summary>
    public enum DSTaskTimeType
    {
        /// <summary>
        /// 周期毫秒
        /// </summary>
        [Description("间隔毫秒")]
        Period,

        /// <summary>
        /// 周期秒
        /// </summary>
        [Description("间隔秒")]
        PeriodSeconds,

        /// <summary>
        /// 周期分钟
        /// </summary>
        [Description("间隔分钟")]
        PeriodMinutes,

        /// <summary>
        /// 周期小时
        /// </summary>
        [Description("间隔小时")]
        PeriodHours,

        /// <summary>
        /// Cron表达式
        /// </summary>
        [Description("Cron表达式")]
        Cron
    }

    /// <summary>
    /// 定时任务
    /// </summary>
    public class DSTask : BaseEntity
    {
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 任务类型 默认流程处理
        /// </summary>
        public DSTaskType Type { get; set; } = DSTaskType.Process;

        /// <summary>
        /// 是否启用 默认不启用
        /// </summary>
        public bool Enable { get; set; } = false;
        ///// <summary>
        /////任务配置 过时
        ///// </summary>
        //[SugarColumn(IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
        //public string TaskConfig { get; set; }

        /// <summary>
        ///任务配置展示
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
        public string TaskConfigView { get; set; }

        /// <summary>
        /// 时间周期类型
        /// </summary>
        public DSTaskTimeType PeriodType { get; set; } = DSTaskTimeType.PeriodSeconds;

        /// <summary>
        /// 周期配置
        /// </summary>
        public string PeriodConfig { get; set; }

        /// <summary>
        /// 流程图配置
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
        public string DiagramData { get; set; }
    }
}